tree grammar HtmlTreeGrammar;

options {
  ASTLabelType = CommonTree; 
  output       = template;
}

// Tokens used internally by Moca
// ID: ('a'..'z' | 'A'..'Z')+;
// STRING: ( ID | ('0'..'9') )+; 
// ATRIBUTE: Used as an imaginary token for coding attributes in XML files (ATTRIBUTE name=ID value=STRING)
tokens {
  ID;
  STRING;
  ATTRIBUTE; 
} 
  
@header {
package org.moflon.moca.html.unparser;
}
// tree grammar rules:
main: ^('Board' r+=row*)
      -> boardTemplate(rows={$r});
      
row: ^('Row' f+=field*)
     -> rowTemplate(fields={$f});
     
field: ^('Field' (n=STRING)?)
       -> fieldTemplate(figure={$n}); 